/*
 * Copyright 2003-2007 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

package com.colony.channel.types;

import java.io.IOException;

import com.argot.TypeException;
import com.argot.TypeInputStream;
import com.argot.TypeReader;
import com.colony.channel.Channel;
import com.colony.channel.ChannelIdentifier;
import com.colony.channel.ChannelServer;

// The incoming version of input stream.
// read off the channel identifier, then connect
// the stream and return the value.

public class ChannelInputStreamServerReader
implements TypeReader
{
	ChannelServer _server;
	
	public ChannelInputStreamServerReader( ChannelServer server )
	{
		_server = server;
	}
	
	public Object read( TypeInputStream in) 
	throws TypeException, IOException
	{
		ChannelIdentifier cid = (ChannelIdentifier) in.readObject(ChannelIdentifier.TYPENAME);
		Channel channel = _server.getChannel(cid.getId());
		return channel.getInputStream();
	}
}